﻿using UnityEngine;
using System.Collections;

public class health : MonoBehaviour {

	
	public GUIStyle progress_empty;
	public GUIStyle progress_full;
	public Player player;
	//current progress
	public float barDisplay;
	
	Vector2 pos = new Vector2(Screen.width/80.8f, Screen.height - Screen.height/10.1f);
	Vector2 size = new Vector2(Screen.width/5.387f,Screen.height/3.03f);
	
	public Texture2D emptyTex;
	public Texture2D fullTex;
	
	void OnGUI()
	{
		GUI.BeginGroup(new Rect(pos.x, pos.y, size.x, size.y), emptyTex, progress_empty);
		
		GUI.BeginGroup(new Rect(0, 0, size.x * barDisplay, size.y));
		
		GUI.Box(new Rect(0, 0, size.x, size.y), fullTex, progress_full);
		
		GUI.EndGroup();
		GUI.EndGroup();
	}
	void Start() {
		player = GetComponent<Player> ();
	}

	void Update()
	{
		barDisplay = player.health/100;
		pos = new Vector2(Screen.width/80.8f, Screen.height - Screen.height/10.1f);
		size = new Vector2(Screen.width/5.387f,Screen.height/3.03f);
	}
	
}